<!doctype html>
<html lang="en">
<?php
include('../confing/common.php');
?>

<head>
    <meta charset="utf-8" />
    <title>用户登录 - <?=$conf['sitename']?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
    <meta content="Themesbrand" name="author" />
    <!-- App favicon -->
    <link rel="shortcut icon" href="assets/images/favicon.ico">

    <!-- Bootstrap Css -->
    <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
    <!-- Icons Css -->
    <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <!-- App Css-->
    <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />

</head>

<body>

    <!-- <div class="home-btn d-none d-sm-block">
        <a href="index.html" class="text-dark"><i class="fas fa-home h2"></i></a>
    </div> -->
    <div class="account-pages my-5 pt-5" id="login">
        <div class="container">
            <div class="row justify-content-center">
                <!-- 登录 - 开始 -->
                <div v-if="loginType" class="col-md-8 col-lg-6 col-xl-5">
                    <div class="card overflow-hidden">
                        <div class="bg-primary">
                            <div class="text-primary text-center p-4">
                                <h5 class="text-white font-size-20 mb-3">用户登录</h5>
                                <a class="logo logo-admin">
                                    <img style="border-radius: 50%;width: 70px;"
                                        :src="'http://q2.qlogo.cn/headimg_dl?dst_uin=' + dl.user + '&spec=100'"
                                        alt="logo">
                                </a>
                            </div>
                        </div>

                        <div class="card-body p-4">
                            
                            <div class="p-3">
                                <form class="form-horizontal mt-4" @submit.prevent="">

                                    <div class="form-group">
                                        <label for="username">账号</label>
                                        <input type="text" class="form-control" v-model="dl.user" placeholder="请输入账号">
                                    </div>

                                    <div class="form-group">
                                        <label for="userpassword">密码</label>
                                        <input type="password" class="form-control" v-model="dl.pass"
                                            placeholder="请输入密码">
                                    </div>

                                    <div class="form-group row">
                                        <div class="col-sm-6 mt-2">
                                            快捷登录：&nbsp;<img src="../assets/images/qq.png" style="height:28px;margin: -4px 5px 0 5px;" id="connect_qq">
                                        </div>
                                        <div class="col-sm-6 text-right">
                                            <button @click="login" class="btn btn-primary w-md waves-effect waves-light"
                                                type="submit">立即登录</button>
                                        </div>
                                    </div>
                                </form>
<span id="runtime_span"  class="btn btn-primary w-md waves-effect waves-light"  ></span>
                            </div>
                        </div>

                    </div>

                    <div class="mt-5 text-center">
                        <p>还没有账号 ? <a @click="newlogin" class="font-weight-medium text-primary"> 点击注册 </a> </p>
                        <p class="mb-0">©
                            <script>document.write(new Date().getFullYear())</script>
                            <?=$conf['sitename']?>
                        </p>
                    </div>

                </div>
                <!-- 登录 - 结束 -->

                <!-- 注册 - 开始 -->
                <div v-else class="col-md-8 col-lg-6 col-xl-5">
                    <div class="card overflow-hidden">
                        <div class="bg-primary">
                            <div class="text-primary text-center p-4">
                                <h5 class="text-white font-size-20 mb-3">用户注册</h5>
                                <a class="logo logo-admin">
                                    <img style="border-radius: 50%;width: 70px;"
                                        :src="'http://q2.qlogo.cn/headimg_dl?dst_uin=' + reg.user + '&spec=100'"
                                        alt="logo">
                                </a>
                            </div>
                        </div>

                        <div class="card-body p-4">
                            <div class="p-3">
                                <form class="form-horizontal mt-4" @submit.prevent="">

                                    <div class="form-group">
                                        <label for="username">昵称</label>
                                        <input type="text" class="form-control" v-model="reg.name" placeholder="请输入昵称">
                                    </div>

                                    <div class="form-group">
                                        <label for="username">邀请码</label>
                                        <input type="text" class="form-control" v-model="reg.yqm" placeholder="请输入邀请码">
                                    </div>

                                    <div class="form-group">
                                        <label for="username">账号</label>
                                        <input type="text" class="form-control" v-model="reg.user"
                                            placeholder="请输入账号(QQ号)">
                                    </div>

                                    <div class="form-group">
                                        <label for="userpassword">密码</label>
                                        <input type="password" class="form-control" v-model="reg.pass"
                                            placeholder="请输入密码">
                                    </div>

                                    <div class="form-group row">
                                        <div class="col-sm-6">
                                        </div>
                                        <div class="col-sm-6 text-right">
                                            <button @click="register"
                                                class="btn btn-primary w-md waves-effect waves-light"
                                                type="submit">立即注册</button>
                                        </div>
                                    </div>

                                </form>
<span id="runtime_span"  class="btn btn-primary w-md waves-effect waves-light"  ></span>
                            </div>
                        </div>

                    </div>

                    <div class="mt-5 text-center">
                        <p>已有账号 ? <a @click="newlogin" class="font-weight-medium text-primary"> 点击登录 </a> </p>
                        <p class="mb-0">©
                            <script>document.write(new Date().getFullYear())</script>
                            <?=$conf['sitename']?>
                        </p>
                    </div>

                </div>
                <!-- 注册 - 结束 -->
            </div>
        </div>
    </div>

    <!-- JAVASCRIPT -->
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="assets/js/fb.min.js"></script>
    <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="assets/libs/metismenu/metisMenu.min.js"></script>
    <script src="assets/libs/simplebar/simplebar.min.js"></script>
    <script src="assets/libs/node-waves/waves.min.js"></script>

    <script src="assets/js/app.js"></script>

    <script src="layer/3.1.1/layer.js"></script>
    <script src="https://cdn.staticfile.org/vue/2.6.11/vue.min.js"></script>
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
     <script type="text/javascript"> function show_runtime() {window.setTimeout("show_runtime()",1000); X=new Date("10/16/2021 5:22:00"); Y=new Date(); T=(Y.getTime()-X.getTime()); M=24*60*60*1000; a=T/M;A=Math.floor(a); b=(a-A)*24;B=Math.floor(b); c=(b-B)*60;C=Math.floor((b-B)*60); D=Math.floor((c-C)*60); runtime_span.innerHTML="本网站站勉强运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime(); </script>
    <script>
        var vm = new Vue({
            el: "#login",
            data: {
                loginType: true,
                title: "你在看什么呢？我写的代码好看吗",
                dl: {},
                reg: {}
            },
            methods: {
                newlogin: function () {
                    this.loginType = !this.loginType
                },
                login: function () {
                    if (!this.dl.user || !this.dl.pass) {
                        layer.msg('账号密码不能为空', {
                            icon: 2
                        });
                        return
                    }
                    var loading = layer.load(2);
                    vm.$http.post("/apisub.php?act=login", {
                        user: this.dl.user,
                        pass: this.dl.pass
                    }, {
                        emulateJSON: true
                    }).then(function (data) {
                        layer.close(loading);
                        if (data.data.code == 1) {
                            layer.msg(data.data.msg, {
                                icon: 1
                            });
                            setTimeout(function () {
                                window.location.href = "/"
                            }, 1000);
                        } else if (data.data.code == 5) {
                            vm.login2();
                        } else {
                            layer.msg(data.data.msg, {
                                icon: 2
                            });
                        }
                    });

                },
                register: function () {
                    if (!this.reg.user || !this.reg.pass || !this.reg.name || !this.reg.yqm) {
                        layer.msg('所有项不能为空', {
                            icon: 2
                        });
                        return
                    }
                    var loading = layer.load(2);
                    this.$http.post("/apisub.php?act=register", {
                        name: this.reg.name,
                        user: this.reg.user,
                        pass: this.reg.pass,
                        yqm: this.reg.yqm
                    }, {
                        emulateJSON: true
                    }).then(function (data) {
                        layer.close(loading);
                        if (data.data.code == 1) {
                            this.loginType = true;
                            this.dl.user = this.reg.user;
                            this.dl.pass = this.reg.pass;
                            layer.msg(data.data.msg, {
                                icon: 1
                            });
                        } else {
                            layer.msg(data.data.msg, {
                                icon: 2
                            });
                        }
                    });
                },
                login2: function () {
                    layer.prompt({
                        title: '管理二次验证',
                        formType: 3
                    }, function (pass2, index) {
                        var loading = layer.load(2);
                        vm.$http.post("/apisub.php?act=login", {
                            user: vm.dl.user,
                            pass: vm.dl.pass,
                            pass2: pass2
                        }, {
                            emulateJSON: true
                        }).then(function (data) {
                            layer.close(loading);
                            if (data.data.code == 1) {
                                layer.msg(data.data.msg, {
                                    icon: 1
                                });
                                setTimeout(function () {
                                    window.location.href = "/"
                                }, 1000);
                            } else {
                                layer.msg(data.data.msg, {
                                    icon: 2
                                });
                            }
                        });
                    });
                }
            }
        });

        $('#connect_qq').click(function () {
            var ii = layer.load(0, {
                shade: [0.1, '#fff']
            });
            $.ajax({
                type: "POST",
                url: "../qq_login.php",
                data: { "type": 'qq' },
                dataType: 'json',
                success: function (data) {
                    layer.close(ii);
                    if (data.code == 1) {
                        window.location.href = data.url;
                    } else {
                        layer.alert(data.msg, {
                            icon: 7
                        });
                    }
                }
            });
        });

    </script>

</body>

</html>